#include "func.h"

typedef enum
{
    CD,LS,PUTS,GETS,REMOVE,PWD,MKDIR,RMDIR

} OrderType;

int whichOrder(char* orderList,int* orderflag,char* args)
{
    char* order = strtok(orderList," ");
    char* tmp = strtok(NULL," ");
    if(tmp != NULL)
    {
        memcpy(args,tmp,strlen(tmp));
    }
    char buf[4];
    strncpy(buf,orderList,3);
    printf("wh buf = %s\n",buf);
    buf[3] = '\0'; 
    
    if(strcmp(order,"cd") == 0)
    {
        *orderflag = CD;
        printf("cd\n");
    }
    else if(strcmp(order,"ls") == 0)
    {
        *orderflag = LS;
        printf("ls\n");
    }
    else if(strcmp(order,"puts") == 0)
    {
        *orderflag = PUTS;
        printf("puts\n");
    }
    else if(strcmp(order,"gets") == 0)
    {
        *orderflag = GETS;
        printf("gets\n");
    }
    else if(strcmp(order,"remove") == 0)
    {
        *orderflag = REMOVE;
        printf("remove\n");
    }
    else if(strcmp(buf,"pwd") == 0)
    {
        *orderflag = PWD;
        printf("pwd\n");
    }
    else if(strcmp(order,"mkdir") == 0)
    {
        *orderflag = MKDIR;
        printf("mkdir\n");
    }
    else if(strcmp(order,"rmdir") == 0)
    {
        *orderflag = RMDIR;
        printf("rmdir\n");
    }
    else
    {
        printf("Illegal Order!\n");
    }
}
